package com.itheima.mall.web.ums;

import com.itheima.mall.pojo.ums.UmsResource;
import com.itheima.mall.service.ums.UmsResourceService;
import com.itheima.mall.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.aggregation.ArrayOperators;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("resource")
public class UmsResourceController {

    @Autowired
    UmsResourceService umsResourceService;

    @PostMapping("create")
    public R UmsResourceCreate(@RequestBody UmsResource umsResource){
        return umsResourceService.UmsResourceCreate(umsResource);
    }

    @PostMapping("delete/{id}")
    public R UmsResourceDelete(@PathVariable Long id){
        return umsResourceService.UmsResourceDelete(id);
    }

    @GetMapping("list")
    public R UmsResourceList(Long categoryId, String nameKeyword, Integer pageNum, Integer pageSize, String urlKeyword){
        return umsResourceService.UmsResourceList(categoryId,nameKeyword,pageNum,pageSize,urlKeyword);
    }

    @GetMapping("listAll")
    public R UmsResourceListAll(){
        return umsResourceService.UmsResourceListAll();
    }

    @PostMapping("update/{id}")
    public R UmsResourceUpdate(@PathVariable Long id, @RequestBody UmsResource umsResource){
        return umsResourceService.UmsResourceUpdate(id,umsResource);
    }

    @GetMapping("{id}")
    public R UmsResourceFindById(@PathVariable Long id){
        return umsResourceService.UmsResourceFindById(id);
    }


}
